package com.lankystar.util;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;


public class ResUtil {

	 public static void toJson(HttpServletResponse response, Object data){

		 Gson gson = new Gson();
	     String result = gson.toJson(data);
	     response.setContentType("text/json; charset=utf-8");
	     response.setHeader("Cache-Control", "no-cache");
	     PrintWriter out;
		try {
			out = response.getWriter();
			out.print(result);
			out.flush();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	 }
	 
}
